<?php
if(isset($_POST['deid']))
{
require("includes/basic.php");
$vdid=$_POST['gvid'];
	$deid=$_POST['deid'];
	$id= split(',',$deid);
	foreach($id as $a => $b)
	{
		$delete=mysql_query("delete from user_master where user_id=$b");
	}

}

if(isset($_POST['dcid']))
{
	require("includes/basic.php");
	$cid=$_POST['dcid'];
	$vdid=$_POST['vid'];
	$id= split(',',$cid);
	foreach($id as $a => $b)
	{
		$deactivate=mysql_query("update user_master set record_status='N' where user_id=$b");
	}
}
if(isset($_POST['acid']))
{
	require("includes/basic.php");
	$vdid=$_POST['gvid'];
	$cid=$_POST['acid'];
	$id= split(',',$cid);
	foreach($id as $a => $b)
	{
		$activate=mysql_query("update user_master set record_status='Y' where user_id=$b");
	}
}
if(isset($_POST['s']))
{
	$s=$_POST['s'];
	$vdid=$_POST['gvid'];
	require("includes/basic.php");
	$sql="select * from user_master where vendor_id=$vdid and (LOWER(first_name) like LOWER('$s%') or LOWER(last_name) like LOWER('$s%'))";
}

else {
$sql= "select * from user_master where vendor_id=$vdid";
}

include('ps_pagination.php'); 
$pager = new PS_Pagination($conn, $sql, 5, 5, "param1=valu1&param2=value2");
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());



$class="evenrowbg";
$sr=1;




?>
<form id='viewvendorcontacts'> 
<input type='hidden' name='vendorid' id="vendorid" value="<?php echo $c; ?>">
	<table width='100%' cellpadding='1' cellspacing='0' class='list'>
	<tr>
		<th width='5%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Sr no.</span>
			</div>
		</th>
        <th width='4%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Edit</span>
			</div>
		</th>
		<!-- <th width='4%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Open</span>
			</div>
		</th> -->
		<th width='11%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">First Name</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Last Name</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Mobile</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">User Name</span>
			</div>
		</th>
		<!--<th width='7%' style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Password</span>
		</th>-->
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Created On</span>
		</th>
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Record Status</span>
		</th>
		
		<th width='5%' class='select'>
			
<input type='checkbox' class='checkbox' name='allCheck' id='listSelectAll'>
		</th>
	</tr>
	<?php while($vendorsr=mysql_fetch_array($rs))
	{
		
		$vendorCid=$vendorsr['user_id'];
		$fname=$vendorsr['first_name'];
		$lname=$vendorsr['last_name'];
		$mobile=$vendorsr['mobile'];
		//$pass=base64_decode($clientsr['password']);
		$user_name=$vendorsr['user_name'];
		$user_password=base64_decode($vendorsr['user_password']);
		//$contact_address=substr($vendorsr['vcontact_address'], 0, 40);
		
		$createdon=$vendorsr['user_created_on'];
		
		$record_status=$vendorsr['record_status'];
		
		
		if($class=="evenrowbg")
		{
			$class="oddrowbg";
		}
		else
		{
			$class="evenrowbg";
		}
		
		
		echo "<tr class='$class'><td style='text-align:center;'>$sr</td>";
		echo "<td style='text-align:center;'><a href='edit-vendor-contact.php?vcid=$vendorCid'><img src='images/user.png'/></a></td>";
		//echo "<td style='text-align:center;'><a href='open-vendorcontact.php?openc=$vendorCid'><img src='images/user.png'/></a></td>";

		//echo "<td style='text-align:center;'><a href='view-client-contacts.php?clid=$contactid'><img src='images/user.png'/></a></td>";
		echo "<td>".$fname."</td><td>".$lname."</td><td>".$mobile."</td><td>".$user_name."</td>";
		
		echo "<td>".$createdon."</td>";
		echo "<td style='text-align:center;'>";
		if($record_status=='Y')
		{
			echo "<img src='images/multi_activate.png' alt='Active' title='Active'>";
		}
		else
		{
			echo "<img src='images/multi_deactivate.png' alt='Disabled' title='Disabled'>";
		}
		
		echo "</td>";
		
		echo "<td style='text-align:center;'><input type='checkbox' value='$vendorCid' id='chkName' name='chkName'></td>";
		$sr++;
		echo "</tr>";
	}

	?>
    </form>

</table>

<?php

	//Display the full navigation in one go
	 echo "<br />\n";?>
	<span style="text-align:justify; margin-left:320px;"><?php  echo $pager->renderFullNav(); ?> </span>